package cn.hutool.benchmark.mybatis;

import org.apache.ibatis.reflection.MetaObject;
import org.apache.ibatis.reflection.factory.ObjectFactory;
import org.apache.ibatis.reflection.property.PropertyTokenizer;
import org.apache.ibatis.reflection.wrapper.MapWrapper;

import java.util.HashMap;
import java.util.Map;

public class CustomMapWrapper extends MapWrapper {
	public CustomMapWrapper(MetaObject metaObject, Map<String, Object> map) {
		super(metaObject, map);
	}

	@Override
	public MetaObject instantiatePropertyValue(final String name, final PropertyTokenizer prop, final ObjectFactory objectFactory) {
		HashMap<String, Object> map = new HashMap<>();
		set(prop, map);
		return MetaObject.forObject(get(prop), metaObject.getObjectFactory(), metaObject.getObjectWrapperFactory(),
				metaObject.getReflectorFactory());
	}
}
